<style type="text/css"> 
b.green{color:DarkGreen;}
b.red  {color:#880000;}
b.code {background:#f9edd4;}
p.code {background:#f9edd4;}
body   {background:#e2fbe4;}
</style><body><pre>
<h3>Kurs: 04 Polygon</h3>
Die Turtle verwaltet ein Polygon.

Script 1: Geschlossenes Polygon zeichnen.
Script 2: Polygon Fill-Optionen.
Script 3: Polygon move.
Script 4: Polygon einfache Mirror-Optionen

<b class="green"b>Vorschlag</b>
  <i>Eigene Befehle ausprobieren.
  Eigenes Script anfgen.</i>

<u>Erklrungen zum Script</u>

* <b class="code">t.beginPolygon();</b>
  <i>Polygon lschen und Polygonmodus einschalten.
  Alle folgenden Bewegungen werden gespeichert.</i>

* <b class="code">t.endPolygon();</b>
  <i>Polygonmodus beenden. Polygon schliesen. Fill=OddEvenFill.</i>

* <b class="code">t.msgPolygon();</b>
  <i>Kontrolle: Polygondaten in der Messagebox anzeigen.</i>

* <b class="code">t.drawPolygon();</b>
  <i>Polygon mit aktuellem Stift und Brush an der
  aktuellen Turtleposition zeichnen. Vor dem Zeichnen
  in Turtlerichtung drehen. Polygon bleibt unverndert</i>

t.movePolygon( x, y); 	 Alle Polygonpunkte durch die verschobenen Punkte ersetzen. Schiebvektor: P0 auf Punkt (x,y).

__________________________________________
<p class="code"><code>
ScriptBegin
var Grafik="Script Turtle";

function init()
{ t.setBrush("LightBlue");
  t.setPage();
  t.clrMsg();
} 

function draw()
{ t.drawKoordSystem();
  t.drawRaster();
  t.setPen("white", 2);

  // Polygon definieren
  t.beginPolygon();
  t.goTo(0,0); t.move(40); t.turn(90); t.move(70); 

  t.endPolygon(); // Default: Fill=0, schliessen und fllen  
  t.msgPolygon(); 

  // Polygon zeichnen
  t.goTo(-80,-80); t.turnTo(0);
  t.setPen("black", 2); t.setBrush("Yellow");
  t.drawPolygon();
 
  t.goTo(-90,40); t.turnTo(-45);
  t.setBrush("red");
  t.drawPolygon();

  t.setPen("green");t.setBrush("blue");
  t.goTo(30,-40); t.turnTo(-90);
  t.drawPolygon();
}

ScriptEnd </code></p>
__________________________________________


Script 2: Polygon Fill-Optionen.

<u>Erklrungen zum Script</u>

* <b class="code">t.endPolygon( Fill );</b>
  <i>Fill 0: schliessen, Qt::OddEvenFill
  Fill 1: schliessen, Qt::WindingFill
  Fill 2: schliessen, nicht fllen
  Fill 3: nicht schliessen, nicht fllen </i>


<p class="code"><code>ScriptBegin
var Grafik="Script Turtle";

function init() //Initialisierungen
{ t.setBrush("LightBlue");
  t.setPage();
} 

function draw() //Zeichenbefehle
{ t.drawKoordSystem();
  t.drawRaster();
  t.setPen("white", 2);

  // Polygon definieren
  t.beginPolygon();
  t.goTo(0,0); t.move(30); t.turn(90); t.move(50); 
  t.endPolygon(3); // Fill: 0,1,2,3

  // Polygon verwenden
  t.goTo(-80,40); t.turnTo(-30);
  t.setPen("black", 2);
  t.setBrush("red");
  t.drawPolygon();
}
ScriptEnd</code></p>
__________________________________________

Script 3: Polygon move.

<u>Erklrungen zum Script</u>

* <b class="code">t.endPolygon( Fill , Mirror);</b>
  <i>Mirror 0: nichts
  Mirror 1: an x-Achse spiegeln, Kopie anhngen
  Mirror 2: an y-Achse spiegeln, Kopie anhngen
  Mirror 3: an x- und y-Achse spiegeln, Kopie anhngen </i>


<p class="code"><code>ScriptBegin
var Grafik="Script Turtle";

function init() //Initialisierungen
{ t.setBrush("LightBlue");
  t.setPage();
} 

function draw() //Zeichenbefehle
{ t.drawKoordSystem();
  t.drawRaster();
  t.setPen("red",1.5);

  // Polygon definieren
  t.beginPolygon();
  t.goTo(10,10); t.turn(30);
  t.move(20); t.turn(30); t.move(40); 
  t.endPolygon(3, 3); // 0,1,2,3

  // Polygon verwenden
  t.goTo(-80,-30); t.turnTo(0);
  t.setPen("black", 2);
  t.setBrush("red");
  t.drawPolygon();
}
ScriptEnd</code></p>

__________________________________________


Script 4: Polygon einfache Mirror-Optionen. M&auml;chtigere 
          Abbildungsfunktionen werden unter
          'Eigene Befehle' beschrieben.

<u>Erklrungen zum Script</u>

* <b class="code">t.endPolygon( Fill , Mirror);</b>
  <i>Mirror 0: nichts
  Mirror 1: an x-Achse spiegeln, Kopie anhngen
  Mirror 2: an y-Achse spiegeln, Kopie anhngen
  Mirror 3: an x- und y-Achse spiegeln, Kopie anhngen </i>


<p class="code"><code>ScriptBegin
var Grafik="Script Turtle";

function init() //Initialisierungen
{ t.setBrush("LightBlue");
  t.setPage();
} 

function draw() //Zeichenbefehle
{ t.drawKoordSystem();
  t.drawRaster();
  t.setPen("red",1.5);

  // Polygon definieren
  t.beginPolygon();
  t.goTo(10,10); t.turn(30);
  t.move(20); t.turn(30); t.move(40); 
  t.endPolygon(3, 3); // 0,1,2,3

  // Polygon verwenden
  t.goTo(-80,-30); t.turnTo(0);
  t.setPen("black", 2);
  t.setBrush("red");
  t.drawPolygon();
}
ScriptEnd</code></p>